<?php

if(!defined('IN_FANWE'))
	exit('Access Denied');

class Memcaches
{
	var $enable;
	var $obj;

	function Memcaches()
	{

	}

	function init($config)
	{
		if(!empty($config['server']))
		{
			$this->obj = new Memcache;
			if($config['pconnect'])
			{
				$connect = @$this->obj->pconnect($config['server'], $config['port']);
			}
			else
			{
				$connect = @$this->obj->connect($config['server'], $config['port']);
			}
			
			$this->enable = $connect ? true : false;
		}
	}

	function get($key)
	{
		return $this->obj->get($key);
	}

	function set($key, $value, $ttl = 0)
	{
		return $this->obj->set($key, $value, MEMCACHE_COMPRESSED, $ttl);
	}

	function rm($key)
	{
		return $this->obj->delete($key);
	}

}
?>